Search
Factory.createDiagramLink Method (DiagramNode, Number | TreeViewItem, DiagramNode, Number | TreeviewItem)
See Also
 





Creates a new DiagramLink instance between the specified nodes and adds it to the links collection of the underlying diagram.

Namespace: MindFusion.Diagramming
Package: Factory.js

 Syntax

JavaScript  Copy Code

function createDiagramLink (
    origin, [originRow], destination, [destRow])

 Parameters

origin
Optional.

DiagramNode. The origin node.

originRow
Optional.

Number | TreeViewItem. The zero-based index of the origin table row or the origin tree item of the new link.

destination
Optional.

DiagramNode. The destination node.

destRow
Optional.

Number | TreeviewItem. The zero-based index of the destination table row or the destination tree item of the new link.

 Return Value

The newly created DiagramLink instance.

 Remarks

If the origin or destination argument refers to a TableNode, it can be optionally followed by a row index specifying the origin or destination row. If the origin or destination argument refers to a TreeViewNode, it can be optionally followed by a TreeViewItem argument specifying the origin or destination item. If index / item arguments are omitted, the link connects to the specified node as a target instead of specific element inside.

 Example

The following script demonstrates various Factory method calls.

JavaScript  Copy Code

function buildDiagram(diagram)
{
    var node = diagram.factory.createShapeNode(10, 50, 40, 30);

    var table = diagram.factory.createTableNode(80, 10, 40, 60);
    table.text = "table";
    table.rowCount = 10;

    var treeView = diagram.factory.createTreeViewNode(150, 90, 40, 60);
    treeView.addItem(new TreeViewItem());
    treeView.addItem(new TreeViewItem());

    diagram.factory.createDiagramLink(node, table, 2);
    diagram.factory.createDiagramLink(table, 4, node);

    diagram.factory.createDiagramLink(treeView, treeView.rootItems[1], node);

    diagram.factory.createDiagramLink(table, 6, treeView, treeView.rootItems[0]);
}

 See Also